package org.crazyit.activiti_d2._3_DeployDiagram;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.ProcessDefinition;

public class DeployDiagram {

    public static void main(String[] args) {

        //1. 创建流程引擎
        ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();

        //2. 得到流程存储服务实例
        RepositoryService repositoryService = engine.getRepositoryService();

        //3. 部署流程描述文件与流程图
        Deployment deploy = repositoryService.createDeployment().addClasspathResource("diagram.bpmn").addClasspathResource("diagram.png").deploy();

        //4. 查询流程定义实体
        ProcessDefinition def = repositoryService.createProcessDefinitionQuery().deploymentId(deploy.getId()).singleResult();

        //5. 输出结果为diagram.png
        System.out.println(def.getDiagramResourceName());

    }

}
